<extend name="Public/Dialog/Common"/>
<block name="pageStyle">
    <style>
        .dragsort li {
            background-color: #fff;
            border: 1px solid #eee;
            height: 30px;
            line-height: 30px;
            margin-bottom: 5px;
            overflow: hidden;
            padding: 0 6px;
        }
    </style>
</block>
<block name="pageContent">
    <div class="bjui-pageContent">
        <form action="{:U('update')}" class="pageForm" data-toggle="validate" method="post">
            <!-- 菜单id号 -->
            <input type="hidden" name="id" value="{:I('id')}">
            <ul class="nav nav-tabs" role="tablist">
                <li class="active"><a href="#Model{$info.id}base" role="tab" data-toggle="tab">基 础</a></li>
                <li><a href="#Model{$info.id}design" role="tab" data-toggle="tab">设 计</a></li>
                <li><a href="#Model{$info.id}expert" role="tab" data-toggle="tab">高 级</a></li>
            </ul>
            <!-- 基础 -->
            <div class="tab-content">
                <div class="tab-pane fade active in" id="Model{$info.id}base">
                    <div class="form-item cf">
                        <label class="item-label">模型标识<span class="check-tips">（请输入文档模型标识）</span></label>
                        <div class="controls">
                            <input type="text" class="text " name="name" value="{$info.name}">
                        </div>
                    </div>
                    <div class="form-item cf">
                        <label class="item-label">模型名称<span class="check-tips">（请输入模型的名称）</span></label>
                        <div class="controls">
                            <input type="text" class="text " name="title" value="{$info.title}">
                        </div>
                    </div>
                    <div class="form-item cf">
                        <label class="item-label">模型类型<span class="check-tips">（目前只支持独立模型和文档模型）</span></label>
                        <div class="controls">
                            <select name="extend">
                                <option value="0" <eq name="info.extend" value="0">selected</eq>>独立模型</option>
                                <option value="1" <eq name="info.extend" value="1">selected</eq>>文档模型</option>
                            </select>
                        </div>
                    </div>
                </div>
                <!-- 设计 -->
                <div class="tab-pane fade" id="Model{$info.id}design">
                    <fieldset>
                        <legend>字段管理<span class="check-tips">（只有新增了字段，该表才会真正建立）</span></legend>
                        <div class="col-md-6">
                            <div class="panel panel-default">
                                <div class="panel-heading">
                                    <span>字段列表
                                        [
                                        <a href="{:U('Attribute/add', array('model_id'=>$info['id'], 'navTabId'=>'AddAttribute'.$info['id']))}" data-toggle="navtab" data-id="AddAttribute{$info.id}" data-title="{$info.name}新增字段">新增</a>
			                            <a href="{:U('Attribute/index', array('model_id'=>$info['id'], 'navTabId'=>'IndexAttribute'.$info['id']))}" data-toggle="navtab" data-id="IndexAttribute{$info.id}" data-title="{$info.name}管理字段">管理</a>
                                        ]
                                    </span>
                                </div>
                                <ul class="dragsort panel-body">
                                    <foreach name="fields" item="field" key="k">
                                        <li class="col-md-4">
                                            <em ><input class="ids" type="checkbox" name="attribute_list[]" value="{$field['id']}" <if condition="in_array($field['id'],$info['attribute_list'])">checked="checked"</if> /> {$field['title']} [{$field['name']}]</em>
                                        </li>
                                    </foreach>
                                </ul>
                                </div>
                            </div>
                        <div class="col-md-3">
                            <div class="form-item cf">
                                <label class="item-label">字段别名定义<span class="check-tips">（用于表单显示的名称）</span></label>
                                <div class="controls">
                                    <label class="textarea input-large">
                                        <textarea name="attribute_alias">{$info.attribute_alias}</textarea>
                                    </label>
                                </div>
                            </div>
                            <div class="form-item cf">
                                <label class="item-label">表单显示分组<span class="check-tips">（用于表单显示的分组，以及设置该模型表单排序的显示）</span></label>
                                <div class="controls">
                                    <input type="text" class="text input-large" name="field_group" value="{$info.field_group}">
                                </div>
                            </div>
                        </div>
                        <div class="col-md-3">
                             <div class="form-item cf">
                                <label class="item-label">列表定义<span class="check-tips">（默认列表模板的展示规则）</span></label>
                                <div class="controls">
                                    <label class="textarea input-large">
                                        <textarea name="list_grid">{$info.list_grid}</textarea>
                                    </label>
                                </div>
                            </div>
                            <div class="form-item cf">
                                <label class="item-label">默认搜索字段<span class="check-tips">（默认列表模板的默认搜索项）</span></label>
                                <div class="controls">
                                    <input type="text" class="text input-large" name="search_key" value="{$info.search_key}">
                                </div>
                            </div>
                            <div class="form-item cf">
                                <label class="item-label">高级搜索字段<span class="check-tips">（默认列表模板的高级搜索项）</span></label>
                                <div class="controls">
                                    <input type="text" class="text input-large" name="search_list" value="{$info.search_list}">
                                </div>
                            </div>
                        </div>
                    </fieldset>

                    <fieldset>
                        <legend>表单显示排序<span class="check-tips">（直接拖动进行排序）</span></legend>
                        <volist name=":parse_field_attr($info['field_group'])" id="vo">
                            <div class="col-md-6">
                            <div class="panel panel-default">
                                <div class="panel-heading">{$vo}</div>
                                <ul class="dragsort needdragsort panel-body" data-group="{$key}">
                                    <foreach name="fields" item="field" key="k">
                                        <if condition="(($field['group'] eq $key) or($i eq 1 and !isset($field['group']))) and ($field['is_show'] eq 1)">
                                            <li class="getSort">
                                                <em data="{$field['id']}">{$field['title']} [{$field['name']}]</em>
                                                <input type="hidden" name="field_sort[{$key}][]" value="{$field['id']}"/>
                                            </li>
                                        </if>
                                    </foreach>
                                </ul>
                            </div>
                            </div>
                        </volist>
                    </fieldset>
                </div>
                <!-- 高级 -->
                <div class="tab-pane fade" id="Model{$info.id}expert">
                    <div class="form-item cf">
                        <label class="item-label">列表模板<span class="check-tips">（自定义的列表模板，放在Application\Admin\View\Think下，不写则使用默认模板）</span></label>
                        <div class="controls">
                            <input type="text" class="text input-large" name="template_list" value="{$info.template_list}">
                        </div>
                    </div>
                    <div class="form-item cf">
                        <label class="item-label">新增模板<span class="check-tips">（自定义的新增模板，放在Application\Admin\View\Think下，不写则使用默认模板）</span></label>
                        <div class="controls">
                            <input type="text" class="text input-large" name="template_add" value="{$info.template_add}">
                        </div>
                    </div>
                    <div class="form-item cf">
                        <label class="item-label">编辑模板<span class="check-tips">（自定义的编辑模板，放在Application\Admin\View\Think下，不写则使用默认模板）</span></label>
                        <div class="controls">
                            <input type="text" class="text input-large" name="template_edit" value="{$info.template_edit}">
                        </div>
                    </div>
                    <div class="form-item cf">
                        <label class="item-label">列表数据大小<span class="check-tips">（默认列表模板的分页属性）</span></label>
                        <div class="controls">
                            <input type="text" class="text input-small" name="list_row" value="{$info.list_row}">
                        </div>
                    </div>
                </div>
            </div>
        </form>
    </div>
</block>
<block name="pageJavascript">
<script type="text/javascript" charset="utf-8">
    //拖曳插件初始化
    $(function(){
        $.CurrentNavtab.find(".needdragsort").dragsort({
            dragSelector:'li',
            placeHolderTemplate: '<li class="draging-place">&nbsp;</li>',
            dragBetween:true,	//允许拖动到任意地方
            dragEnd:function(){
                var self = $(this);
                self.find('input').attr('name', 'field_sort[' + self.closest('ul').data('group') + '][]');
            }
        });
    })
</script>
</block>